<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2020/10/12
 * Time: 4:06 PM
 */
namespace app\admin\logic;


use app\event\ModifyIntegral;
use app\model\IntegralLog;
use app\model\User;
use app\model\UserReport;
use app\model\UserVideo;
use app\model\Video;
use think\facade\Db;
use think\facade\Request;

class UserReportLogic
{

    /*
     * 获取报告列表 默认周报
     */
    public function getReportList(){

        $orgId = config('user')['orgid'];

        $param = Request::get();
        $where = [
            ['ur_orgid','=',$orgId],
            ['ur_status','=',1],
        ];

        if(isset($param['type']) && !empty($param['type'])){
            $where[] = ['ur_type','=',intval($param['type'])];
        }

        if(isset($param['startTime']) && !empty($param['startTime'])){
            $where[] = ['ur_create_time','>=',strtotime(date('Y-m-d',$param['startTime']))];
        }

        if(isset($param['endTime']) && !empty($param['endTime'])){
            $where[] = ['ur_create_time','<=',strtotime(date('Y-m-d 23:59:59',$param['endTime']))];
        }

        if(isset($param['pername']) && !empty($param['pername'])){
            $where[] = ['pername','like','%'.trim($param['pername']).'%'];
        }

        $reportModel = new UserReport();

        return $reportModel->getReportListByCondition($where);
    }
}